import Vue from 'vue'
import VueRouter from 'vue-router'
import U_Login from '@/views/client/Login.vue' //@代表src
import U_Register from '@/views/client/Register.vue'
import Layout from '@/components/layout/Layout.vue'
import M_Login from "@/views/manager/Login";
import W_Login from "@/views/worker/Login";
import BackStage from "@/views/manager/BSM/BackStage";
import WorkerBG from "@/views/worker/WorkerBG";

Vue.use(VueRouter)

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: "/",
        redirect: '/home'//地址重定向到首页
      },
      {
        path: "/home",//首页
        component: () => import("@/views/client/Home.vue")
      },
      {
        path: "/movie",//电影页面
        component: () => import("@/views/client/Movie.vue")
      },
      {
        path: "/activity",//活动页面
        component: () => import("@/views/client/Activity.vue")
      },
      {
        path: "/message",//留言页面
        component: () => import("@/views/client/Message.vue")
      },
      {
        path: "/movie_detail",//电影详情页面
        component: () => import("@/views/client/movie/Index.vue"),
        children: [
          {
            path: "",
            component: () => import("@/views/client/movie/Detail.vue")
          },
          {
            path: "ticket",
            component: () => import("@/views/client/movie/Ticket.vue")
          },
        ]
      },
      {
        path: "/personal_center",//个人中心页面
        component: () => import("@/views/client/personal_center/Index.vue"),
        children: [
          {
            path: "",
            redirect: 'shopping_cart'
          },
          {
            path: "shopping_cart",
            component: () => import("@/views/client/personal_center/Cart.vue")
          },
          {
            path: "my_order",
            component: () => import("@/views/client/personal_center/Order.vue")
          },
          {
            path: "basic_setting",
            component: () => import("@/views/client/personal_center/Setting.vue")
          },
        ]
      },
      {
        path: "/selection",
        component: () => import("@/views/client/movie/Selection.vue")
      },
    ]
  },
  {
    path: '/login',//用户登录页面
    name: "login",
    component: U_Login
  },
  {
    path: '/register',
    name: 'register',
    component: U_Register
  },
  {
    path: '/w_login',
    name: 'w_login',
    component: W_Login
  },
  {
    path: '/m_login',
    name: 'm_login',
    component: M_Login
  },

  {
    path: '/BackStage',
    name: 'BackStage',
    component: BackStage,
    children: [
      {
        path: '',
        redirect: "FilmMg/filmList"
      },
      {
        path: 'FilmMg/filmList',
        component: () => import("@/views/manager/BSM/filmMg/FilmList.vue"),
      },
      {
        path: 'FilmMg/arrangementList',
        component: () => import("@/views/manager/BSM/filmMg/ArrangementList.vue"),
      },
      {
        path: 'FilmMg/addFilm',
        component: () => import("@/views/manager/BSM/filmMg/AddFilm.vue"),
      },
      {
        path: 'FilmMg/CarouselPicture',
        component: () => import("@/views/manager/BSM/filmMg/CarouselPicture.vue"),
      },
      {
        path:'UserMg/userList',
        component:() => import("@/views/manager/BSM/userMg/UserList.vue"),
      },
      {
        path:'OrderMg/orderList',
        component:() => import("@/views/manager/BSM/orderMg/OrderList.vue"),
      },
      {
        path:'OrderMg/ExceptiveOrder',
        component:() => import("@/views/manager/BSM/orderMg/ExceptiveOrder.vue"),
      },
      {
        path:'WorkerMg/workerList',
        component:() => import("@/views/manager/BSM/workerMg/WorkerList.vue"),
      },
      {
        path:'WorkerMg/workerAdd',
        component:() => import("@/views/manager/BSM/workerMg/Add.vue"),
      },

    ]
  },

  {
    path: '/w_login',
    name: 'w_login',
    component: W_Login
  },

  {
    path: '/WorkerBG',
    name: 'WorkerBG',
    component: WorkerBG,
    children:[
      {
        path: '',
        redirect: "messageList"
      },
      {
        path: 'messageList',
        component: () => import("@/views/worker/BGW/MessageList.vue"),
      },
      {
        path: 'activityList',
        component: () => import("@/views/worker/BGW/ActivityList.vue"),
      },
      {
        path: 'evaluationList',
        component: () => import("@/views/worker/BGW/EvaluationList.vue"),
      },
      {
        path: 'set',
        component: () => import("@/views/worker/BGW/Set.vue"),
      },
      
    ]
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
